package com.imut.lagain.service;
import org.slf4j.LoggerFactory;

import com.imut.lagain.entity.MemoryCapsule;

import org.springframework.scheduling.annotation.Async;

import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

public interface IPushService {
    @Async
    CompletableFuture<Boolean> sendCapsuleOpenNotification(Long userId, MemoryCapsule capsule);

    @Async
    CompletableFuture<Boolean> sendCapsuleOpenReminder(Long userId, MemoryCapsule capsule, long hoursLeft);

    @Async
    CompletableFuture<Integer> sendSystemNotice(Long userId, String title, String content, String page);

    @Async
    CompletableFuture<Boolean> sendSecurityAlert(Long userId, String alertType, String alertContent);

    @Async
    CompletableFuture<Integer> batchSendCapsuleReminders(List<MemoryCapsule> capsules, long hoursLeft);

    @Async
    CompletableFuture<Integer> batchSendCapsuleOpenNotifications(List<MemoryCapsule> capsules);

    /**
     * 记录推送历史
     *
     * @param userId   用户ID
     * @param pushType 推送类型
     * @param content  推送内容
     * @param success  是否成功
     */
    void recordPushHistory(Long userId, String pushType, String content, boolean success);

    List<Object> getUserPushHistory(Long userId, int limit);

    Map<String, Object> getPushStats(String pushType, int days);

    boolean checkPushPermission(Long userId, String pushType);

    void setPushPermission(Long userId, String pushType, boolean enabled);

    /**
     * 截断字符串到指定长度
     *
     * @param str       原字符串
     * @param maxLength 最大长度
     * @return 截断后的字符串
     */
    String truncateString(String str, int maxLength);

    boolean isPushServiceAvailable();

    Map<String, Object> getPushServiceStatus();
}
